package com.ruoyi.web.controller.hsz.param;

import com.ruoyi.system.domain.HszArticle;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.util.Date;
import java.util.List;

@Data
public class HszArticleEditParam {
    private Long articleId;

    /**
     * 分类
     */
    @NotNull(message = "分类不能为空")
    private Long clazzId;

    /**
     * 标题
     */
    @NotBlank(message = "标题不能为空")
    @Length(max = 100, message = "标题长度不能超过100个字符")
    private String title;

    /**
     * 内容
     */
    private String content;

    /**
     * 类型
     */
    @NotBlank(message = "类型不能为空")
    @Pattern(regexp = "^(富文本|图片|视频|外链)$", message = "类型可选范围：富文本、图片、视频、外链")
    private String type;

    /**
     * 封面
     */
    @Length(max = 255, message = "封面长度不能超过255个字符")
    private String coverUrl;

    /**
     * 发布人
     */
    @Length(max = 20, message = "发布人长度不能超过20个字符")
    private String publishEr;

    /**
     * 发布日期
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date publishDate;

    /**
     * 是否置顶
     */
    private Boolean isTop = false;

    /**
     * 是否轮播
     */
    private Boolean isRotate = false;

    /**
     * 附件
     */
    private List<String> fj;

    public HszArticle toDO(){
        HszArticle hszArticle = new HszArticle();
        hszArticle.setArticleId(articleId);
        hszArticle.setClazzId(clazzId);
        hszArticle.setTitle(title);
        hszArticle.setContent(content);
        hszArticle.setType(type);
        hszArticle.setCoverUrl(coverUrl);
        hszArticle.setPublishEr(publishEr);
        hszArticle.setPublishDate(publishDate);
        hszArticle.setIsTop(isTop);
        hszArticle.setIsRotate(isRotate);
        hszArticle.setFj(fj);
        return hszArticle;
    }
}
